<template>
  <div :class="{'hidden':hidden}" class="pagination-container">
     <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="pageSizes"
      :page-size="pageSize"
      :layout="layout"
      size="mini"
      style="margin: -10px;"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: 'Pagination',
  props: {
    total: {
      required: true,
      type: Number,
      default: 0
    },
    page: {
      type: Number,
      default: 1
    },
    pageSizes: {
      type: Array,
      default () {
        return [10, 20, 30, 50]
      }
    },
    pageSize: {
      type: Number,
      default: 20
    },
    currentPage: {
      type: Number,
      default: 1
    },
    layout: {
      type: String,
      default: 'total, sizes, prev, pager, next, jumper'
    },
    hidden: {
      type: Boolean,
      default: false
    }
  },
  computed: {

  },
  methods: {
    handleSizeChange (val) {
      this.$emit('pagination', { current: this.currentPage, size: val, total: this.total })
    },
    handleCurrentChange (val) {
      this.$emit('pagination', { current: val, size: this.pageSize, total: this.total })
    }
  }
}
</script>

<style scoped>
.pagination-container {
  background: #fff;
  padding: 32px 16px;
}
.pagination-container.hidden {
  display: none;
}
</style>
